package com.xuecheng.manage_course.client;

import com.xuecheng.framework.domain.cms.CmsPage;
import com.xuecheng.framework.domain.cms.response.CmsPageResult;
import com.xuecheng.framework.domain.cms.response.CmsPostPageResult;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

@FeignClient(value = "XC-SERVICE-MANAGE-CMS") // 指定远程调用的服务名,Feign会从注册中心获取cms服务列表，并通过负载均衡算法进行服务调用
public interface CmsPageClient {
    /*
        1、feignClient接口 有参数在参数必须加@PathVariable("XXX")和@RequestParam("XXX")
        2、feignClient返回值为复杂对象时其类型必须有无参构造函数。
     */

    // 根据页面id查询页面信息，远程调用cms请求数据
    @GetMapping("cms/page/get/{id}")
    CmsPage findCmsPageById(@PathVariable("id") String id);

    @PostMapping("cms/page/save")
    CmsPageResult save(@RequestBody CmsPage cmsPage);

    @PostMapping("cms/page/postPageQuick")
    CmsPostPageResult postPageQuick(@RequestBody CmsPage cmsPage);
}
